<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use app\common\model\coll\Analysis;
use app\common\model\stock\Loss;
use app\common\model\Storehouse;
use app\common\model\purchase\Order;
use app\common\model\purchase\Enter;
use app\common\model\purchase\Retreat;
use app\common\model\purchase\Diff;
use app\common\model\purchase\Allot;
use app\common\model\purchase\Goods;
use app\common\model\sales\Slip;
use app\common\model\sales\Checkout;
use app\common\model\sales\Retreat as salesRetreat;
use app\common\model\sales\Change;
use app\common\model\sales\Goods as salesGoods;
use app\common\model\factory\Sales;
/**
 * 控制台
 *
 * @icon fa fa-dashboard
 * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
 */
class Config extends Backend
{

    public function zaxconfig(){
     
        $states = input('states/d',0);
        switch ($states){
            case 1://仓库
                $where = [];
                if(!empty(session('admin')['storehouse_id'])){
                    $where['id'] = session('admin')['storehouse_id'];
                }
                $list = Storehouse::where($where)->select();
                $houses = [];
                foreach ($list as $v){
                    $houses[] = $v['name'];
                }
                return json($houses);
                break;
            case 2://采购单状态
                $model = new Order;
                return $model->order_status();
                break;
            case 3://入库单状态
                $model = new Enter;
                return $model->enter_status();
                break;
            case 4://采购退货单状态
                $model = new Retreat;
                return $model->retreat_status();
                break;
            case 5://非经营性调整状态
                $model = new Diff;
                return $model->diff_status();
                break;
            case 6://同价调拨单状态
                $model = new Allot;
                return $model->allot_status();
                break;
            case 7://全部仓库
                $list = Storehouse::where([])->select();
                $houses = [];
                foreach ($list as $v){
                    $houses[$v['id']] = $v['name'];
                }
                return json($houses);
            case 8://销售单状态
                $model = new Slip;
                return $model->slip_status();
                break;
            case 9://销售出库单状态
                $model = new Checkout();
                return $model->checkout_status();
                break;
            case 10://销售换货单状态
                $model = new Change();
                return $model->change_status();
                break;
            case 11://销售退货单状态
                $model = new salesRetreat();
                return $model->retreat_status();
                break;
            case 12://采购商品状态
                $model = new Goods();
                return $model->goods_status();
                break;
            case 13://采购商品状态
                $model = new salesGoods();
                return $model->goods_status();
                break;
            case 14://采购分析状态
                $model = new Analysis();
                $list = $model->an_status();
                return  $list;
                break;
            case 15://商品请购状态
                $model = new Goods();
                return $model->goods_status();
                break;
            case 16://直发单状态
                $model = new Sales();
                return $model->slip_status();
                break;
            case 17://报损报溢单状态
                $model = new Loss();
                return $model->loss_status();
                break;
            case 18://所有单据类型
                return dill_type();
                break;
        }

    }
}
